#!/bin/bash

# 项目清理脚本
# 清理不需要的文件和目录，保持项目结构整洁

echo "开始清理项目..."

# 清理备份文件
echo "清理备份文件..."
find . -name "backup" -type d -exec rm -rf {} + 2>/dev/null || true

# 清理编译缓存
echo "清理编译缓存..."
find . -name "obj" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name "bin" -type d -exec rm -rf {} + 2>/dev/null || true

# 清理构建输出
echo "清理构建输出..."
find . -name "build" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name "dist" -type d -exec rm -rf {} + 2>/dev/null || true

# 清理锁文件（保留package.json）
echo "清理锁文件..."
find . -name "package-lock.json" -delete 2>/dev/null || true
find . -name "yarn.lock" -delete 2>/dev/null || true

# 清理IDE和编辑器文件
echo "清理IDE文件..."
find . -name ".vscode" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name ".idea" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name "*.user" -delete 2>/dev/null || true
find . -name "*.suo" -delete 2>/dev/null || true
find . -name "*.userosscache" -delete 2>/dev/null || true

# 清理临时文件
echo "清理临时文件..."
find . -name "*.tmp" -delete 2>/dev/null || true
find . -name "*.log" -delete 2>/dev/null || true
find . -name "*.cache" -delete 2>/dev/null || true
find . -name ".DS_Store" -delete 2>/dev/null || true
find . -name "Thumbs.db" -delete 2>/dev/null || true

# 清理空文件
echo "清理空文件..."
find . -name "CLAUDE.md" -size 0 -delete 2>/dev/null || true

echo "清理完成！"
echo ""
echo "项目结构概览："
echo "=================="
find . -type d -not -path "./.git/*" -not -path "*/node_modules/*" -not -path "./.claude/*" -not -path "./.continue/*" | head -20
echo "..."